#pragma once

#include "interaction/EventHandler.h"
#include "interaction/IEventHandlers.h"

class EventHandlers : public IEventHandlers
{
	typedef std::vector<IEventHandler*> ActiveEventHandlerStack;
	typedef std::map<vclsid,sys::ObjectPtr> CachedEventHandlers;

public:
	BEGIN_DEFINE_CLASS(CLSID_EventHandlers)
		DEFINE_INTERFACE_ENTRY(IEventHandler)
		DEFINE_INTERFACE_ENTRY(IEventHandlers)
	END_DEFINE_CLASS()

	EventHandlers();
	virtual ~EventHandlers();

	virtual void StartEvents(const InteractionInput& input);

	virtual IEventHandler* Push(vclsid clsidEventHandler,EventInfo* info=NULL);
	virtual uint32 Count() const;

	virtual void EventLoopBegin();
	virtual bool Event(SystemEventArgs* e);
	virtual void Draw();
	virtual void EventLoopEnd();

private:
	CachedEventHandlers m_cachedEventHandlers;
	ActiveEventHandlerStack m_activeEventHandlers;
	InteractionInput m_input;
};

AUTO_REGISTER_CLASSMAP_ENTRY(EventHandlers)